<?php
class Cerad_Context
{
	protected $dbx       = NULL;
	protected $dbEayso   = NULL;
	protected $requestx  = NULL;
	protected $responsex = NULL;
	
	protected $params;
	
	public function __construct($params)
	{
		$this->params = $params;	
	}
	function __get($name)
	{
		switch($name)
		{
		case 'db':      return $this->getDb();
		case 'dbEayso': return $this->getDbEayso();
		}
	}
	public function getDb()
	{
		if (!$this->dbx) 
		{
			$this->dbx = new Cerad_DatabaseAdapter($this->params['db']);
			
		}
		return $this->dbx;
	}
	public function getDbEayso()
	{
		if (!$this->dbEayso) 
		{
			$this->dbEayso = new Cerad_DatabaseAdapter($this->params['dbEayso']);
		}
		return $this->dbEayso;
	}
	function getRequest()
	{
		if (!$this->requestx) 
		{
			$this->requestx = new Cerad_Request($this);
		}
		return $this->requestx;
	}
	function setRequest($request) { $this->requestx = $request; }
	
	function getResponse()
	{
		if (!$this->responsex) 
		{
			$this->responsex = new Cerad_Response($this);
		}
		return $this->responsex;
	}
}
?>